home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows1 / bwtool01.zip / FASTPRT.ASM < prev    next >
Assembly Source File  |  1986-11-30  |  5KB  |  98 lines

  1. bios_data         segment     at 40H      ; set up labels to determine whether
  2.                   org         10H         ; to display in color or monochrome
  3. equip_flag        label       word
  4.                   org         4AH         ; 40 or 80 column display
  5. crt_clms          label       word
  6.                   org         63H
  7. addr_6845         label       word        ; pointer to video card ports
  8. bios_data         ends
  9.  
  10. code              segment     byte public 'CODE'
  11.                   assume      cs:code,ds:code
  12.                   public      FASTPRT
  13.  
  14. FASTPRT           proc        far
  15.                   push        bp            ; save BP for far return
  16.                   mov         bp,sp         ; point to arguments on stack
  17.                   push        es            ; must save for BASIC
  18.  
  19.                   mov         bx,[bp+8]     ; get addr of COL% storage
  20.                   mov         di,[bx]       ; get the column value
  21.                   dec         di            ; adjust for LOCATE format
  22.  
  23.                   mov         bx,[bp+10]    ; get addr of ROW% storage
  24.                   mov         ax,[bx]       ; get the row value
  25.                   dec         ax            ; adjust for LOCATE format
  26.  
  27.                   mov         bx,[bp+12]    ; set ptr to string descriptor
  28.                   mov         cx,[bx]       ; get length of string
  29.                   jcxz        exit          ; Done if null string
  30.                   mov         si,[bx+2]     ; SI = first character of VAR$
  31.  
  32.                   mov         bx,bios_data  ; set ready to determine video card
  33.                   mov         es,bx         ; and number of columns
  34.                   mul         es:crt_clms   ; AX = COL% times words per line
  35.                   add         di,ax         ; DI = words from start of screen
  36.                   shl         di,1          ; shift for attribute byte
  37.  
  38. ;       CX has the count of characters to write
  39. ;       SI points to the string to print
  40. ;       DI points to the starting screen position
  41.  
  42.                   mov         ax,0B000H          ;default to mono card
  43.                   mov         bx,es:equip_flag
  44.                   and         bx,30H
  45.                   cmp         bx,30H             ; monochrome?
  46.                   je          mono               ; jump if so
  47.                   mov         ax,0B800h          ; set to color card
  48.                   mov         dx,es:addr_6845    ; point to 6845 base port
  49.                   add         dx,6               ; point to status port
  50.                   mov         bx,[bp+6]          ; get color attribute
  51.                   mov         bx,[bx]
  52.                   mov         es,ax              ; point ES to video
  53.  
  54.                   call        print_string
  55.  
  56.                   jmp         exit
  57.  
  58. mono:             mov         dx,es:addr_6845    ; point to 6845 base port
  59.                   add         dx,6               ; point to status port
  60.                   mov         bx,[bp+6]          ; get color attribute
  61.                   mov         bx,[bx]
  62.                   mov         es,ax              ; point ES to video
  63.  
  64. movestr:          movsb                          ; print a character
  65.                   mov        es:[di],bl          ; move attribute
  66.                   inc        di                  ; skip attribute byte
  67.                   loop       movestr             ; repeat until end of string
  68. exit:
  69.                   pop         es
  70.                   pop         bp
  71.                   ret         8
  72. FASTPRT           endp
  73.  
  74. Print_string      proc       near                ; wait for horizontal retrace
  75.                   cli                            ; turn off interrupts
  76. test_low:         in         al,dx               ; get status
  77.                   test       al,1                ; is it low?
  78.                   jnz        test_low            ; if not, try again
  79. test_hi:          in         al,dx               ; get status
  80.                   test       al,1                ; is it high?
  81.                   jz         test_hi             ; if not, try again
  82.                   movsb                          ; print a character
  83. tst_low2:         in         al,dx               ; get status
  84.                   test       al,1                ; is it low?
  85.                   jnz        tst_low2            ; if not, try again
  86. tst_hi2:          in         al,dx               ; get status
  87.                   test       al,1                ; is it high?
  88.                   jz         tst_hi2             ; if not, try again
  89.                   mov        es:[di],bl          ; move attribute
  90.                   inc        di                  ; skip attribute byte
  91.                   loop       test_low            ; repeat until end of string
  92.                   sti                            ; turn interrupts back on
  93.                   ret                            ; return to the FASTPRT procedure
  94. Print_string      endp
  95.  
  96. code              ends
  97.                   end
  98.